
/**
 * 菜单树视图 js
 */
Ext.namespace("oa.functions.tree");


oa.functions.tree.store = Ext.create('Ext.data.TreeStore', {
	    id:'tree_store',
	    proxy: {
	        type: 'ajax',
	        url: '../../function/loadFunctionTree.do',
	        reader: {
	            type: 'json'
	        }
	    },
	     root:{expanded: true} ,
	    autoLoad: true
	});


oa.functions.tree.view=Ext.create('Ext.tree.Panel', {
				title: "菜单目录",
				region: "west",
				split: true,
				width:"30%",
				store:oa.functions.tree.store,
				rootVisible: false,  //默认不显示根节点
				collapsible: true,
				tools: [{
			        type: 'refresh',
			        tooltip: '刷新',
			        // hidden:true,
			        handler: function() {//Ext.data.Store load
			            oa.functions.tree.store.load({
			                scope: this,
			                callback: function(records, operation, success) {
			                	oa.functions.tree.view.expandAll();
			                }
			            });
			        }
			    }],
				listeners: {
			        'load' : function(){
			            oa.functions.tree.view.expandAll();
			        }, 
			
			        'itemclick': function(view, record, item, index, e) {
			            nodeId = record.raw.id; //获取点击的节点id
			            nodeText = record.raw.text; //获取点击的节点text
			            //Ext.Msg.alert("提示信息", nodeId + nodeText);
			            oa.functions.tree.selectNode=record;
			            if(record.raw.leaf==false){
			            	oa.functions.table.store.proxy.url="../../function/loadTable.do?pid="+nodeId;
			            	oa.functions.index.refreshTable();
			            }
			
			        }
			    }

			})


